public class RemoteController {
    private Command[] onCommands;       //开按钮
    private Command[] offCommands;      //关按钮
    private Command cancel;             //撤销按钮

    public RemoteController() {
        onCommands = new Command[5];
        offCommands = new Command[5];
        for (int i = 0; i < 5; i++) {
            onCommands[i] = new NoCommand();
            offCommands[i] = new NoCommand();
        }
    }

    public void setOnCommands(int no, Command command){
        onCommands[no]=command;
    }

    public void setoffCommands(int no,Command command){
        offCommands[no]=command;
    }

    public void onPressButton(int no){
        onCommands[no].exectute();
        cancel = onCommands[no];
    }

    public void offPressButton(int no){
        offCommands[no].exectute();
        cancel = offCommands[no];
    }

    public void pressCancel(){
        cancel.undo();
    }
}
